package Q225

import java.util.*

class Main {

}

fun main(){

}

class MyStack() {

    var queue1 : Queue<Int> = LinkedList()
    var queue2 : Queue<Int> = LinkedList()

    fun push(x: Int) {
        queue2.offer(x)
        while (!queue1.isEmpty()){
            queue2.offer(queue1.poll())
        }

        var queueTemp : Queue<Int> = LinkedList()
        queueTemp = queue1
        queue1 = queue2
        queue2 = queueTemp
    }

    fun pop(): Int {
        return queue1.poll()
    }

    fun top(): Int {
        return queue1.peek()
    }

    fun empty(): Boolean {
        return queue1.isEmpty()
    }

}

/**
 * Your MyStack object will be instantiated and called as such:
 * var obj = MyStack()
 * obj.push(x)
 * var param_2 = obj.pop()
 * var param_3 = obj.top()
 * var param_4 = obj.empty()
 */